//
//  AESubmitOrderDeliveryWayView.m
//  AESOLAR_IOS
//
//  Created by Bin Tang on 2024/10/15.
//  Copyright © 2024 Mr.Wang. All rights reserved.
//

#import "AESubmitOrderDeliveryWayView.h"
#import "AE_Solar-Swift.h"

@interface AESubmitOrderDeliveryWayView ()

/// 标题
@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *defaultLabel;

@property (nonatomic, strong) UIImageView *tagImgView;

@property (nonatomic, strong) UILabel *remarkLabel;


- (void)initWithTitleLabel;

- (void)initWithDefaultLabel;

- (void)initWithTagImgView;

- (void)initWithRemarkLabel;


@end

@implementation AESubmitOrderDeliveryWayView

- (void)initWithSubView {
    [super initWithSubView];
    
    self.backgroundColor = kWhiteColor;
    self.layer.cornerRadius = 6;
    self.layer.masksToBounds = YES;
}

- (void)initWithTitleLabel {
    if (!_titleLabel) {
        NSString *title = [AEStringExten localizedValueWithKey:@"派送方式"];
        UIFont *font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
        float width = [title widthForFont:font] + 10;
        CGRect frame = CGRectMake(14, 15, width, 22);
        _titleLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#333333"];
            label.text = title;
        }];
    }
}

- (void)initWithDefaultLabel {
    if (!_defaultLabel) {
        NSString *title = [AEStringExten localizedValueWithKey:@"默认"];
        UIFont *font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
        float width = [title widthForFont:font] + 10;
        CGRect frame = CGRectMake(self.width - 14 - width, 15, width, 22);
        _defaultLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#F60911"];
            label.textAlignment = NSTextAlignmentRight;
        }];
    }
}

- (void)initWithTagImgView {
    if (!_tagImgView) {
        CGRect frame = CGRectMake(14, self.defaultLabel.bottom + 11, 12, 12);
        _tagImgView = [UIImageView createWithImageView:self frame:frame defaultImage:nil propertiesBlock:^(UIImageView * _Nonnull imageView) {
            imageView.backgroundColor = [UIColor colorWithHexString:@"#E39237"];
            imageView.layer.cornerRadius = frame.size.height * 0.5;
            imageView.layer.masksToBounds = YES;
        }];
    }
}

- (void)initWithRemarkLabel {
    if (!_remarkLabel) {
        NSString *title = [AEStringExten localizedValueWithKey:@"用户请联系客服并领取"];
        UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        CGRect frame = CGRectMake(self.tagImgView.right + 5, 0, self.width - self.tagImgView.right - 5 - 14, 20);
        _remarkLabel = [UILabel createWithLabel:self frame:frame font:font propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#999999"];
            label.text = title;
        }];
    }
    self.remarkLabel.centerY = self.tagImgView.centerY;
}

- (void)updateWithViewData:(id)data {
    
    [self initWithTitleLabel];

    [self initWithDefaultLabel];

    [self initWithTagImgView];

    [self initWithRemarkLabel];

}


@end
